<!DOCTYPE HTML>
<html xmlns=" http://www.w3.org/1999/xhtml">
    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>showStorage</title>
		        <script type="text/javascript" src="../js/loaclstore.js"/>

        <script type="text/javascript">
        	
			
//            window.addEventListener('storage', function(e){
//                console.log(e.key + "'s value is changed from '" +
//                e.oldValue +
//                "' to '" +
//                e.newValue +
//                "' by " +
//                e.url);
//            }, false);
            
            
            
            
			        localStorage.setItem("name", '李康');

            console = {
                log: function(string){
                    var logItem = document.getElementById("log");
                    var temp = logItem.innerHTML;
                    logItem.innerHTML = temp + "<br>" + string;
                    
                }
                
            }
            function supports_html5_storage(){
                try {
                    return typeof(localStorage) != "undefined";
                } 
                catch (e) {
                    return false;
                }
            }
            
            function showStorage(){
                if (supports_html5_storage()) {
                    for (var i = 0; i < localStorage.length; i++) {
                        var key = localStorage.key(i);
                        console.log(key + ":" + localStorage[key]);
                    }
                }
            }
            
			
			
			
		


            
        </script>
    </head>
    <body>
        <p>
            This is a paragraph.
        </p>
        <button onclick="showStorage()">
            showStorage()
        </button>
		<button onclick="localStorage.clear()">
           localStorage.clear()
        </button>
			<button onclick="alert(UserData.getItem('name'))">
           UserData.getItem()
        </button>
		<button onclick="UserData.setItem('name','hi李康');UserData.setItem('age','890120')">
           UserData.setItem()
        </button>
        <br>
        <div id="log">
        </div>
    </body>
</html>
